From 5bc6ea904a435a94c4d9565d3ae50a4eb55c1ae8 Mon Sep 17 00:00:00 2001 From: robertl Date: Wed, 12 Feb 2003 03:45:22 +0000 Subject: [PATCH] Fix up filter wreckage I introduced with new arg parsing. From Mottram. --- duplicate.c | 10 +++------- filter_vecs.c | 6 ++++++ position.c | 17 +++++++++++------ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/duplicate.c b/duplicate.c index 6dbf569fe..1f29ee2d6 100644 --- a/duplicate.c +++ b/duplicate.c @@ -23,8 +23,6 @@ extern queue waypt_head; -static int duplicate_shortname = 0; -static int duplicate_location = 0; static char *snopt = NULL; static char *lcopt = NULL; @@ -149,7 +147,7 @@ duplicate_process(void) { queue * elem, * tmp; waypoint * waypointp; - btree_node * newnode, * btmp, * ftmp, * sup_tree = NULL; + btree_node * newnode, * btmp, * sup_tree = NULL; unsigned long crc = 0; struct { char shortname[32]; char lat[13]; char lon[13]; } dupe; waypoint * delwpt = NULL; @@ -159,11 +157,11 @@ duplicate_process(void) memset(&dupe, '\0', sizeof(dupe)); - if (duplicate_shortname) { + if (snopt) { strncpy(dupe.shortname, waypointp->shortname, sizeof(dupe.shortname) - 1); } - if (duplicate_location) { + if (lcopt) { /* let sprintf take care of rounding */ sprintf(dupe.lat, "%11.6f", waypointp->position.latitude.degrees); sprintf(dupe.lon, "%11.6f", waypointp->position.longitude.degrees); @@ -198,8 +196,6 @@ duplicate_process(void) void duplicate_init(const char *args) { - duplicate_shortname = snopt != NULL; - duplicate_location = lcopt != NULL; } void diff --git a/filter_vecs.c b/filter_vecs.c index 47e22ba72..4dc76b0de 100644 --- a/filter_vecs.c +++ b/filter_vecs.c @@ -103,9 +103,15 @@ void disp_filter_vecs(void) { fl_vecs_t *vec; + arglist_t *ap; + for (vec = filter_vec_list; vec->vec; vec++) { printf(" %-20.20s %-50.50s\n", vec->name, vec->desc); + for (ap = vec->vec->args; ap && ap->argstring; ap++) { + printf(" %-18.18s %-.50s\n", + ap->argstring, ap->helpstring); + } } } diff --git a/position.c b/position.c index 3a53fe98b..5e69f5e0b 100644 --- a/position.c +++ b/position.c @@ -29,6 +29,13 @@ extern queue waypt_head; static double pos_dist; +static char *distopt; + +static +arglist_t position_args[] = { + {"distance", &distopt, "Maximum positional distance (required)"}, + {0, 0, 0} +}; static double gc_distance(double lat1, double lon1, double lat2, double lon2) @@ -117,18 +124,16 @@ position_process(void) void position_init(const char *args) { char *fm; - char *p; - p = get_option(args, "distance"); + pos_dist = 0; - if (p) { - pos_dist = strtod(p, &fm); + if (distopt) { + pos_dist = strtod(distopt, &fm); if ((*fm == 'm') || (*fm == 'M')) { /* distance is meters */ pos_dist *= 3.2802; } - xfree(p); } } @@ -140,5 +145,5 @@ filter_vecs_t position_vecs = { position_init, position_process, position_deinit, - NULL + position_args }; -- 2.30.2